<?php
/**
 * Created by PhpStorm.
 * User: jin
 * Date: 2015/8/24
 * Time: 16:06
 */

namespace Home\Model;


class Upload
{
    /**
     * 上传医院图片
     * @param String $fielName
     * @param String $saveName
     * @return array
     */
    static function uploadImage($fielName,$saveName){
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     3145728 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath  =     './Uploads/'; // 设置附件上传根目录
        $upload->replace  =     true; // 存在同名文件是否是覆盖，默认为false
        $upload->saveName = $saveName;
        $upload->autoSub = false;
        // 上传文件
        $info   =   $upload->uploadOne($_FILES[$fielName]);
        if(!$info) {// 上传错误提示错误信息
            return array('sta'=>false,$upload->getError());
        }else{// 上传成功
            return array('sta'=>true,'fileName'=>'./Uploads/'.$info['savename']);
        }
    }
}